#!/bin/bash
#
# lib/cinder_backends/ceph
# Configure the ceph backend

# Enable with:
#
#   CINDER_ENABLED_BACKENDS+=,ceph:ceph

# Dependencies:
#
# - ``functions`` file
# - ``cinder`` configurations

# configure_ceph_backend_lvm - called from configure_cinder()


# Save trace setting
_XTRACE_CINDER_CEPH=$(set +o | grep xtrace)
set +o xtrace


# Defaults
# --------


# Entry Points
# ------------

# configure_cinder_backend_ceph - Set config files, create data dirs, etc
# configure_cinder_backend_ceph $name
function configure_cinder_backend_ceph {
    local be_name=$1

    iniset $CINDER_CONF $be_name volume_backend_name $be_name
    iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.rbd.RBDDriver"
    iniset $CINDER_CONF $be_name rbd_ceph_conf "$CEPH_CONF_FILE"
    iniset $CINDER_CONF $be_name rbd_pool "$CINDER_CEPH_POOL"
    iniset $CINDER_CONF $be_name rbd_user "$CINDER_CEPH_USER"
    iniset $CINDER_CONF $be_name rbd_secret_uuid "$CINDER_CEPH_UUID"
    iniset $CINDER_CONF $be_name rbd_flatten_volume_from_snapshot False
    iniset $CINDER_CONF $be_name rbd_max_clone_depth 5
    iniset $CINDER_CONF DEFAULT glance_api_version 2
}

# Restore xtrace
$_XTRACE_CINDER_CEPH

# Local variables:
# mode: shell-script
# End:
